Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Validations for equals() and not_equals() #1952

Merged
merged 6 commits into from
Apr 19, 2019

Conversation

MGatner
Copy link
Member

@MGatner MGatner commented Apr 17, 2019

Description
Per conversation in Slack, there is currently no way to check a precise value (or not), such as confirming a user typed "yes". This adds validation rules for equals and not_equals, along with their language texts, user guide entires, and tests.

Checklist:

  • Securely signed commits
  • Component(s) with PHPdocs
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

system/Validation/Rules.php Outdated Show resolved Hide resolved
system/Validation/Rules.php Outdated Show resolved Hide resolved
@atishhamte
Copy link
Contributor

Please provide the unit test case related to all the datatype and string case sensitive and insensitive comparison.
Also update the user guide as well.

@nowackipawel
Copy link
Contributor

nowackipawel commented Apr 18, 2019

Could not we just use in_list / not_in_list / regex rules ?

@MGatner
Copy link
Member Author

MGatner commented Apr 18, 2019

@nowackipawel While those supply overlapping functionality, they make for weird error messages such as "The confirmation field must be one of: yes." This allows for clearer messages as well as easier to understand code.

@MGatner
Copy link
Member Author

MGatner commented Apr 18, 2019

Please provide the unit test case related to all the datatype and string case sensitive and insensitive comparison.
Also update the user guide as well.

I accidentally sent user guide and tests to my develop branch. I included those and added tests for case sensitivity. Data types are irrelevant because rules "must accept a string as the first parameter" (https://codeigniter4.github.io/CodeIgniter4/libraries/validation.html#creating-custom-rules).

Null gets cast as empty string so is actually true, even though the datatypes are initially different.
@lonnieezell lonnieezell merged commit 9bdfb13 into codeigniter4:develop Apr 19, 2019
@MGatner MGatner deleted the validation-equals-notequals branch April 19, 2019 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants